<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>设备风险标记记录表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">支付表</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">VIN</div>
                    <div class="field">
                        <input name="vin" id="vin" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">标记人</div>
                    <div class="field">
                        <input name="crtUsrNm" id="crtUsrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">标记类型</div>
                    <div class="field">
                        <input name="signResType" id="signResType" data-value="" placeholder="--请选择--" ltype="combobox">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">标记原因</div>
                    <div class="field">
                        <input name="signResCd" id="signResCd" data-value="" placeholder="--请选择--" ltype="combobox">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <%--<span id="clearBtn" class="sq-button sq-button-round">清空</span>--%>
                    <sys:funcAuth resCd="rsk_prd_sign_add">
                        <span id="addBtn" class="sq-button sq-button-round">新增</span>
                    </sys:funcAuth>
                    <%--<span id="changeBtn" class="sq-button sq-button-round">修改</span>--%>
                    <sys:funcAuth resCd="rsk_prd_sign_delete">
                        <span id="delBtn" class="sq-button sq-button-round">删除</span>
                    </sys:funcAuth>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/risk/rskPrdSignLog/initList.do',
            method: 'get',
            columns: [
                {display: '支付表', name: 'paySchNo', minWidth: 180, align: 'center', enabledSort: false},
                {display: '状态', name: 'prdStsCd', minWidth: 100, align: 'center', enabledSort: false},
                {display: '起租日期', name: 'lsDt', minWidth: 120, align: 'center', enabledSort: false},
                {display: '项目类型', name: 'prjTypCd', minWidth: 100, align: 'center', enabledSort: false},
                {display: '事业部', name: 'buOrgCd', minWidth: 100, align: 'center', enabledSort: false},
                {display: 'VIN', name: 'vin', minWidth: 180, align: 'center', enabledSort: false},
                {display: '标记类型', name: 'signResTypeNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '标记原因', name: 'signResCd', minWidth: 100, align: 'center', enabledSort: false},
                {display: '标记时间', name: 'crtTMNM', minWidth: 120, align: 'center', enabledSort: false},
                {display: '原始标记人', name: 'crtUsrNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '更新时间', name: 'mdfTMNM', minWidth: 120, align: 'center', enabledSort: false},
                {display: '最新标记人', name: 'mdfUsrNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '备注', name: 'signRem', minWidth: 180, align: 'center', enabledSort: false},
                {
                    display:'操作',width:250,
                    render:function (rowdata, rowindex, value){
                        var h="";

                        h+='<a class="sq-button-hasicon" href="javascript:seeById(';
                        h+="'"+rowdata.id+"'";
                        h+=")\"><i class='sqBtnIco_32'></i>查看</a>";

                        h+='<sys:funcAuth resCd="rsk_prd_sign_modify"><a class="sq-button-hasicon" href="javascript:saveById(';
                        h+="'"+rowdata.id+"'";
                        h+=')"><i class="sqBtnIco_4"></i>修改</a></sys:funcAuth>';

                        /*h+='<a class="sq-button-hasicon" href="javascript:dremoveById(';
                        h+="'"+rowdata.id+"'";
                        h+=")\"><i class='sqBtnIco_7'></i>删除</a>";*/
                        return h;
                    }
                }

            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            $.ligerDialog.open({
                width: 1100,
                height: 450,
                title: '新增设备风险标记记录表',
                url:'<%=path%>/risk/rskPrdSignLog/toAddPage.do'
            });
            //Add_navTab("RskPrdSignLog_1", "新增设备风险标记记录表", '<%=path%>/risk/rskPrdSignLog/toAddPage.do', callback);
        });

        /* 修改 */
        $("#changeBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length != 1) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                return;
            }
            var _id=selectedRows[0].id;
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '修改设备风险标记记录表',
                url:'<%=path%>/risk/rskPrdSignLog/toModifyPage.do?id='+_id
            });
            //Add_navTab('RskPrdSignLog_2'+_id, "修改设备风险标记记录表", '<%=path%>/risk/rskPrdSignLog/toModifyPage.do?id='+_id, callback);
        });

        /* 删除 */
        $("#delBtn").click(function () {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }

            $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/risk/rskPrdSignLog/removeByIds.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });

    });

    /* 修改 */
    function saveById(_id) {
        if (!_id)return;
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/risk/rskPrdSignLog/getById.do?id=' + _id,
            success: function (msg) {
                if (msg.success == 1) {
                    $.ligerDialog.open({
                        width: 1100,
                        height: 450,
                        title: '修改设备风险标记记录表',
                        url:'<%=path%>/risk/rskPrdSignLog/toModifyPage.do?id='+_id
                    });
                    //Add_navTab('RskPrdSignLog_2'+_id, "修改设备风险标记记录表", '<%=path%>/risk/rskPrdSignLog/toModifyPage.do?id='+_id, callback);
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //单个删除数据
    function dremoveById(_id) {
        if (!_id)return;
        $.ligerDialog.confirm('确定删除吗?', function (flag) {
            if (flag == false)return;
            var wait_dialog;
            $.ajax({
                type: 'get',
                dataType: 'json',
                url: '<%=path%>/risk/rskPrdSignLog/removeById.do?id=' + _id,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        grid.reload($('.pcontrol input', grid.toolbar).val());
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    /* 查看 */
    function seeById(_id) {
        if (!_id)return;
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/risk/rskPrdSignLog/getById.do?id=' + _id,
            success: function (msg) {
                if (msg.success == 1) {
                    $.ligerDialog.open({
                        width: 800,
                        height: 300,
                        title: '查看设备风险标记记录表',
                        url:'<%=path%>/risk/rskPrdSignLog/toSeePage.do?id='+_id,
                        buttons: [
                            {
                                text: "关闭", onclick: onCancel, type: 'cancel'
                            }
                        ]
                    });
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }


    $("#signResCd").ligerComboBox({
        valueField: 'key',
        textField: 'value'
    });
    $("#signResType").ligerComboBox({
        valueField: 'key',
        textField: 'value'
    });
    liger.get("signResCd").setData(${signResCdList});
    liger.get("signResType").setData(${signResTypeList});

</script>

</body>
</html>
